/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package gestionmagasins_aspectj_junit_patterns.model;

import java.util.ArrayList;

/**
 *
 * @author Michael
 * Correspond à la classe Catalogue du modèle du domaine et modèle de conception. 
 * Renommé Catalogue pour CatalogueArticle afin d'éviter toutes confusions potentielles étant donné que d'autres catalogues existent.
 */
public class CatalogueArticles {
    
    private ArrayList<Article> articles;
    
    private static CatalogueArticles catalogueArticles;
    
    public static synchronized CatalogueArticles getCatalogueArticles(){
        if(catalogueArticles == null)
            catalogueArticles = new CatalogueArticles();
        return catalogueArticles;
    }
    
    private CatalogueArticles(){
        articles = new ArrayList<Article>();
        
    }
    
    public int getNombreArticles(){
     
        return articles.size();
    }
    
    public ArrayList<Article> getListe(){
        
        return (ArrayList<Article>)articles.clone();
    }
    
    public Article getArticle(int position){
        
        return articles.get(position);
    }
    
    public Article creerArticle(TypeArticle type){
        Article newArticle = ArticleFactory.CreateArticle(type);
        return newArticle;
    }
    
    public Article creerArticle(TypeArticle type, String codeArticle, String nom, String description, Taille taille, double prix, int quantiteEnInventaire){
        Article newArticle = ArticleFactory.CreateArticle(type);
        newArticle.setCodeArticle(codeArticle);
                newArticle.setNom(nom);
                newArticle.setDescription(description);
                newArticle.setTaille(taille);
                newArticle.setPrix(prix);
                newArticle.setQuantiteEnInventaire(quantiteEnInventaire);
                
        return newArticle;
    }
    
    public void addArticle(Article newArticle){
        
        articles.add(newArticle);
    }
    
    public void deleteArticle(Article articleToRemove){
        
        articles.remove(articleToRemove);
    }
    
}
